Extracting transactional data

Promotional data are data about customers, such as addresses, names and phone numbers. In Connect, each record in the extracted record set represents one recipient. The number of fields that contain promotional data is the same in each record. These data are stored on the root level of the extracted record.
Transactional data, on the other hand, are used in communications about transactions between a company and their customers or suppliers: invoices, statements, and purchase orders, for example. Naturally these data differ per customer. They are stored in detail tables in the extracted record. The number of fields in a detail table can vary from record to record.

Detail tables are created when an Extract step is added within a Repeat step. The Repeat step goes through a number of lines or nodes. An Extract step within that loop extracts data from each line or node.
It depends on the type of source data how this loop is constructed exactly.

For more information about detail tables, multiple detail tables and nested detail tables, see Detail tables.

From a CSV file or a Database

The transactional data (also called line items) appear in multiple rows.

  1. Select a field in the column that contains the first line item information.

  2. Right-click this data selection and select Add Repeat.

    This adds a Repeat step with a GoTo step inside it. The GoTo step moves the cursor down to the next line, until there are no more lines (see Goto step).

  3. (Optional.) Add an empty detail table via the Data Model pane: right-click the Data Model and select Add a table. Give the detail table a name.

  4. Select the Repeat step on the Steps pane.

  5. Start extracting data (see Adding an extraction).
    When you drag & drop data on the name of a detail table in the Data Model pane, the data are added to that detail table.
    Dropping the data somewhere else on the Data Model pane creates a new detail table, with a default name that you can change later on (see Renaming a detail table).
    The extraction step is placed inside the Repeat step, just before the GoTo step.

From an XML file

The transactional data appears in repeated elements.

  1. Right-click one of the repeating elements and select Add Repeat.

    This adds a Repeat step to the data mapping configuration.
    By default, the Repeat type of this step is set to For Each, so that each of the repeated elements is extracted. You can see this on the Step properties pane, as long as the Repeat step is selected on the Steps pane. In the Collection field, you will find the corresponding node path.

    You may edit the XPath in the Collection field, to include or exclude elements from the loop. One example of this is given in a How-to: Using Xpath in a Repeat step.
    The example in the How-to uses the

    starts-with()

    function. For an overview of XPath functions, see Mozilla: XPath Functions.
    In addition, it is possible to use JavaScript statements in an XPath in the Collection field to dynamically select elements; see Repeat Definition.


    The Goto step isn't used in XML extraction workflows The DataMapper moves through the file using Xpath, a path-like syntax to identify and navigate nodes in an XML document.

  2. (Optional.) Add an empty detail table via the Data Model pane: right-click the Data Model and select Add a table. Give the detail table a name.

  3. Select the Repeat step on the Steps pane.

  4. Extract the data: inside a repeating element, select the data that you want to extract. Then right-click the selected nodes and select Add Extraction, or drag & drop them in the Data Model.
    When you drag & drop data on the name of a detail table in the Data Model pane, the data are added to that detail table.
    Dropping the data somewhere else on the Data Model pane creates a new detail table, with a default name that you can change later on (see Renaming a detail table).
    The new Extract step will be located in the Repeat step.

From a Text or a PDF file

In a PDF or Text file, transactional data appears on multiple lines and can be spread over multiple pages.

  1. Add a Goto step if necessary. Make sure that the cursor is located where the extraction loop must start. By default the cursor is located at the top of the page, but previous steps may have moved it. Note that an Extract step does not move the cursor.

    1. Select something in the first line item.

    2. Right-click on the selection and select Add Goto. The Goto step will move the cursor to the start of the first line item.

  2. Add a Repeat step where the loop must stop.

    1. In the line under the last line item, look for a text that can be used as a condition to stop the loop, for example "Subtotals",  Total" or "Amount".

    2. Select that text, right-click on it and select Add Repeat. The Repeat step loops over all lines until the selected text is found.

  3. Include/exclude lines. Lines between the start and end of the loop that don't contain a line item must be excluded from the extraction. Or rather, all lines that contain a line item have to be included. This is done by adding a Condition step within the Repeat step.

    1. Select the start of the Repeat step on the Steps pane.

    2. Look for something in the data that distinguishes lines with a line item from other lines (or the other way around). Often, a "." or "," appears in prices or totals at the same place in every line item, but not on other lines.

    3. Select that data, right-click on it and select Add Conditional.

      Selecting data - especially something as small as a dot - can be difficult in a PDF file. To make sure that a Condition step checks for certain data:Type the value in the right operand (in the Step properties pane).Move or resize the selection rectangle in the data.Click the Use selection button in the left operand (in the Step properties pane).When the Condition evaluates to true, the value is found in the selected region.


    In the Data Viewer, you will see a green check mark in the left margin next to each included line and an X for other lines.

  4. (Optional.) Add an empty detail table to the Data Model: right-click the Data Model and select Add a table. Give the detail table a name.

  5. Extract the data (see Adding an extraction).
    When you drag & drop data on the name of a detail table in the Data Model pane, the data are added to that detail table.
    Dropping the data somewhere else on the Data Model pane, or using the contextual menu in the Data Viewer, creates a new detail table, with a default name that you can change later on (see Renaming a detail table).

    In a PDF or Text file, pieces of data often have a variable size: a product description, for example, may be short and fit on one line, or be long and cover two lines. To learn how to handle this, see Extracting data of variable length.

  6. Extract the sum or totals. If the record contains sums or totals at the end of the line items list, the end of the Repeat step is a good place to add an Extract step for these data. After the loop step, the cursor position is at the end of line items.

    1. Select the amount or amounts.

    2. Click on the end of the Repeat step () in the Steps panel.

    3. Right-click on the selected data and select Add Extraction.

    Alternatively, right-click on the end of the Repeat step in the Steps panel and select Add a Step > Add Extraction.

This how-to describes in detail how to extract an item description that appears in a variable number of lines: How to extract multiline items.